package com.cjy.ComparatorDemo1;

import java.util.*;


public class TestComparator {
    public static void main(String[] args) {

        List<ComparatorBusiness> list = new ArrayList<>();
        list.add(new ComparatorBusiness("黄鹤楼",25));
        list.add(new ComparatorBusiness("白沙",15));
        list.add(new ComparatorBusiness("真龙",10));
        list.add(new ComparatorBusiness("海韵",50));
        ComparatorBusiness name = Collections.max(list,new ComparatorClass());
        System.out.println("最大值: "+name.getName()+name.getGrades());

        Collections.sort(list,new ComparatorClass());
        System.out.print("升序后:");
        for (int i=0;i<list.size();i++){
            System.out.print(" " +list.get(i).getName()+list.get(i).getGrades());
        }

        System.out.println();
        System.out.print("降序后:");
        Collections.reverse(list);
        for (int i=0;i<list.size();i++){
            System.out.print(" " +list.get(i).getName()+list.get(i).getGrades());
        }

        System.out.println();
        System.out.print("随机:");
        Collections.shuffle(list);
        for (int i=0;i<list.size();i++){
            System.out.print(" " +list.get(i).getName()+list.get(i).getGrades());
        }
    }
}
